const http = require('./http.js') //请求
import helper from './helper.js' //静态变量

// 获取openId
export const getOpenId = (datas) => {
  // return http._post('/label/WxApi/getOpenId', datas, false, false)
  const accountInfo = wx.getAccountInfoSync();
  const appId = accountInfo.miniProgram.appId;
  return http._post('/label/open/getUnionId', {
    ...datas,
    appId
  }, false, false)
}


//获取oneId
export const getOneId = (datas) => {
  return http._post('/label/smallProgram/generateOneId', datas, false, false)
}

// 获取活动
export const getSmallProgramActivities = (datas) => {
  return http._post('/label/activity/getSmallProgramActivities', datas, false, false)
}

// 获取经销商信息
export const getUserAllInfo = (datas) => {
  return http._post('/logon/user/queryUserAllInfo', datas, false, false)
}


// // 潜客分析
// export const addAnalysisLog = (datas) => {
//   let options = {
// 		baseUrl: helper.manuAdmin_url,
// 		header: {
// 			'content-type': 'application/x-www-form-urlencoded' // 表单提交
// 		},
//   }
//   return  http._post(`/userLog/addUserLog`, datas, false, false, options)
// }

//城市列表
export const getCitysList = () => {
  return http._post(`/logon/dept/queryCityListByDeptId`)
}
//品牌运营位
export const getBrandList = (datas) => {
  return http._post(`/label/carMakeOrder/getCarMakeOrderList`,datas,false,false)
}
//车系运营位
export const getCarModelList = (datas) => {
  return http._post(`/label/carModelOrder/getCarModelOrderList`,datas,false,false)
}
//全部车型
export const getModelPage = (datas) => {
  return http._post(`/label/smallProgram/pageOrderStyle`,datas,false,false)
}
// 获取用户信息
export const getWxUser = (datas) => {
  return http._post('/label/WxApi/getWxUser', datas, false, false)
}

// 保存用户信息
export const addWxUser = (datas) => {
  return http._post('/label/WxApi/addWxUser', datas, false, false)
}

// 活动详情
export const getActivityInfo = (datas) => {
  return http._post('/label/activity/getActivityInfo', datas, false, false)
}

//获取首页父品牌下的车系列表
export const getSelectCarModel = (datas) => {
  return http._post(`/label/smallProgram/getSelectCarModel`,datas,false,false)
}

//车系级别
export const getCarModelLevel = (datas) => {
  return http._post(`/label/smallProgram/getCarModelLevel`,datas,false,false)
}
//根据车系获取车型列表
export const getCarStyle = (datas) => {
  return http._post(`/label/smallProgram/getCarStyle`,datas,false,false)
}

//询底价
export const postAskPrice = (datas) => {
  
  return http._post(`/clue/original/save`,datas,false,false)
}

export const getActivityInfoAndSingUpStatus = (datas) => {
  return http._post('/label/smallProgram/getActivityInfoAndSingUpStatus', datas, false, false)
}

// 获取手机号
export const decrypt = (datas) => {
  const accountInfo = wx.getAccountInfoSync();
  const appId = accountInfo.miniProgram.appId;
  return http._post('/label/WxApi/decrypt', {
    ...datas,
    appId
  }, false, false)
}

// 活动报名
export const addSignUp = (datas) => {
  return http._post('/label/smallProgram/addSignUp', datas, false, false)
}

// 获取经销商
export const queryDealerByCityNameAndCarSeriesId = (datas) => {
  return http._post('/logon/dept/queryDealerByCityNameAndCarSeriesId', datas, false, false)
}

// 参加的活动和礼物
export const joinActivities = (datas) => {
  return http._post('/label/smallProgram/joinActivities', datas, false, false)
}
// 我的券码
export const myCouponList = (datas) => {
  return http._post('/label/myCoupon/list', datas, false, false)
}
//广告运营位
export const AdvertisingList = (datas) => {
  return http._post('/saasAdmin/operate/pageList',datas,false,false,{
    header:{
      'Content-Type': 'application/json'
    },
  })
}

//=======================================================================
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync(): {}
//首页商品列表
export const goodsList = (datas) => {
  return http._post('/mall/goods/getAppletList', datas, false, false,{
    header:{
        'Content-Type': 'application/json'
    },
  })
}
//商品详情
export const goodsDetail = (datas) => {
  return http._post('/mall/goods/getInfo', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//根据手机号查询角色
export const userRole = (datas) => {
  return http._post('/logon/user/queryUserRoleByPhone', datas, false, false)
}
//测试微信支付
// export const wxPay = (datas) => {
//   return http._post('/mall/order/portal/wxpay', datas, false, false)
// }
//收货地址列表
export const addressList = (datas) => {
  return http._get('/mall/portal/receiver/address/list', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//新增/修改 地址
export const addAddress = (datas) => {
  return http._post('/mall/portal/receiver/address/save', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//删除地址
export const deleteAddress = (datas) => {
  return http._get('/mall/portal/receiver/address/delete', datas, false, false)
}
//生成订单-调微信支付
export const generate = (datas) => {
  return http._post('/mall/portal/order/generate', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//我的订单 
export const myOrder = (datas) => {
  return http._post('/mall/portal/order/page', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//取消订单
export const cancelOrder = (datas) => {
  return http._get('/mall/portal/order/cancel', datas, false, false)
}
//删除订单
export const deleteOrder = (datas) => {
  return http._get('/mall/portal/order/delete', datas, false, false)
}
//确认收货
export const receiveOrder = (datas) => {
  return http._get('/mall/portal/order/receive', datas, false, false)
}
//所属部门id--拿取礼金包id-- B端
export const assignDetail = (datas) => {
  return http._post('/mall/portal/gifts/assign/page', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//礼金包信息  C端
export const giftInfo = (datas) => {
  return http._post('/mall/gifts/getInfo', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//我的礼券 列表
export const giftsPage = (datas) => {
  return http._get('/mall/portal/gifts/receive/mine', datas, false, false)
}
//领取礼金
export const takeReceive = (datas) => {
  return http._post('/mall/portal/gifts/receive', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
//生成一条原始线索
export const giftsClue = (datas) => {
  return http._post(`/clue/original/save`,datas,false,false)
}
//我的订单 -付款
export const paymentAlign = (datas) => {
  return http._post('/mall/portal/order/pay', datas, false, false,{
    header:{
        'Content-Type': 'application/json',
        'tenantId': extConfig.tenantId || ''
    },
  })
}
// 城市--拿经销商
export const getOneDept = (datas) => {
  return http._get('/logon/portal/getOneDept', datas, false, false)
}